|
1
|
|
|
GLSR.colorControls = function() |
|
|
|
|
|
|
2
|
|
|
{ |
|
3
|
|
|
if( typeof x.wp !== 'object' || typeof x.wp.wpColorPicker !== 'function' )return; |
|
|
|
|
|
|
4
|
|
|
x( document ).find( 'input[type="text"].color-picker-hex' ).each( function() { |
|
5
|
|
|
x( this ).wpColorPicker( x( this ).data( 'colorpicker' ) || {} ); |
|
6
|
|
|
}); |
|
7
|
|
|
}; |
|
8
|
|
|
|
|
9
|
|
|
GLSR.insertNotices = function( notices ) |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
if( !notices )return; |
|
12
|
|
|
if( !x( '#glsr-notices' ).length ) { |
|
13
|
|
|
x( '#message.notice' ).remove(); |
|
14
|
|
|
x( 'form#post' ).before( '<div id="glsr-notices" />' ); |
|
15
|
|
|
} |
|
16
|
|
|
x( '#glsr-notices' ).html( notices ); |
|
17
|
|
|
x( document ).trigger( 'wp-updates-notice-added' ); |
|
18
|
|
|
}; |
|
19
|
|
|
|
|
20
|
|
|
GLSR.onClearLog = function( ev ) |
|
|
|
|
|
|
21
|
|
|
{ |
|
22
|
|
|
var request = { |
|
23
|
|
|
action: 'clear-log', |
|
24
|
|
|
}; |
|
25
|
|
|
GLSR.postAjax( ev, request, function( response ) { |
|
|
|
|
|
|
26
|
|
|
GLSR.insertNotices( response.notices ); |
|
|
|
|
|
|
27
|
|
|
x( '#log-file' ).val( response.logger ); |
|
28
|
|
|
}); |
|
29
|
|
|
}; |
|
30
|
|
|
|
|
31
|
|
|
GLSR.pointers = function( pointer ) |
|
32
|
|
|
{ |
|
33
|
|
|
x( pointer.target ).pointer({ |
|
34
|
|
|
content: pointer.options.content, |
|
35
|
|
|
position: pointer.options.position, |
|
36
|
|
|
close: function() { |
|
37
|
|
|
x.post( ajaxurl, { |
|
|
|
|
|
|
38
|
|
|
pointer: pointer.id, |
|
39
|
|
|
action: 'dismiss-wp-pointer', |
|
40
|
|
|
}); |
|
41
|
|
|
}, |
|
42
|
|
|
}) |
|
43
|
|
|
.pointer( 'open' ) |
|
44
|
|
|
.pointer( 'sendToTop' ); |
|
45
|
|
|
x( document ).on( 'wp-window-resized', function() { |
|
46
|
|
|
x( pointer.target ).pointer( 'reposition' ); |
|
47
|
|
|
}); |
|
48
|
|
|
}; |
|
49
|
|
|
|
|
50
|
|
|
GLSR.postAjax = function( ev, request, callback ) |
|
|
|
|
|
|
51
|
|
|
{ |
|
52
|
|
|
ev.preventDefault(); |
|
53
|
|
|
var el = x( ev.target ); |
|
54
|
|
|
if( el.is( ':disabled' ))return; |
|
55
|
|
|
request.nonce = request.nonce || el.closest( 'form' ).find( '#_wpnonce' ).val(); |
|
56
|
|
|
var data = { |
|
57
|
|
|
action: site_reviews.action, |
|
|
|
|
|
|
58
|
|
|
request: request, |
|
59
|
|
|
}; |
|
60
|
|
|
el.prop( 'disabled', true ); |
|
61
|
|
|
x.post( site_reviews.ajaxurl, data, function( response ) { |
|
|
|
|
|
|
62
|
|
|
if( typeof callback === 'function' ) { |
|
63
|
|
|
callback( response ); |
|
64
|
|
|
} |
|
65
|
|
|
el.prop( 'disabled', false ); |
|
66
|
|
|
}); |
|
67
|
|
|
}; |
|
68
|
|
|
|
|
69
|
|
|
GLSR.textareaResize = function( el ) |
|
|
|
|
|
|
70
|
|
|
{ |
|
71
|
|
|
var minHeight = 320; |
|
72
|
|
|
var textarea = el[0]; |
|
73
|
|
|
textarea.style.height = 'auto'; |
|
74
|
|
|
textarea.style.height = textarea.scrollHeight > minHeight ? textarea.scrollHeight + 'px' : minHeight + 'px'; |
|
75
|
|
|
}; |
|
76
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.